/* 产品 */
import { selectProductInfo, selectProductInfoById, insertProduct, updateProduct, deleteProduct } from '../service/product.js';

/* 获取产品信息 */
const getProduct = async (ctx, next) => {
  selectProductInfo(ctx, next);
};

/* 根据id获取产品信息 */
const getProductById = async (ctx, next) => {
  selectProductInfoById(ctx, next);
};
/* 保存产品信息 */
const saveProduct = async (ctx, next) => {
  insertProduct(ctx, next);
};

/* 保存产品信息 */
const putProduct = async (ctx, next) => {
  updateProduct(ctx, next);
};

/* 保存产品信息 */
const delProduct = async (ctx, next) => {
  deleteProduct(ctx, next);
};

/* 注意请求方式后面的空格 */
export default {
  'GET /product/page': getProduct,
  'GET /product/:id': getProductById,
  'POST /product': saveProduct,
  'PUT /product/:id': putProduct,
  'DELETE /product/:id': delProduct,
};